#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>

#include "settingdialog.h"

SettingDialog::SettingDialog(QWidget *parent) :
    QDialog(parent)
{
    createWidgets();
    createLayout();
    createConnections();

    setWindowTitle(tr("Setting."));
}

void SettingDialog::createWidgets()
{
    emailLabel = new QLabel(tr("E-mail:"),this);
    passwordLabel = new QLabel(tr("Password:"),this);
    pop3AddressLabel = new QLabel(tr("POP3 Address:"),this);
    smtpAddressLabel = new QLabel(tr("SMTP Address:"),this);
    ownerEmailLabel = new QLabel(tr("Owner E-mail:"),this);

    emailEdit = new QLineEdit(this);
    passswordEdit = new QLineEdit(this);
    passswordEdit->setEchoMode(QLineEdit::Password);
    pop3AddressEdit = new QLineEdit(this);
    smtpAddressEdit = new QLineEdit(this);
    ownerEmailEdit = new QLineEdit(this);

    emailLabel->setBuddy(emailEdit);
    passwordLabel->setBuddy(passswordEdit);
    pop3AddressLabel->setBuddy(pop3AddressEdit);
    smtpAddressLabel->setBuddy(smtpAddressEdit);
    ownerEmailLabel->setBuddy(ownerEmailEdit);
    listenMailBox = new QCheckBox(tr("Watch on E-mail Box"), this);
    okButton = new QPushButton(tr("OK"), this);
    cancelButton = new QPushButton(tr("Cancel"), this);
}

void SettingDialog::createLayout()
{
    QGridLayout *editLayout = new QGridLayout;
    editLayout->addWidget(emailLabel,0,0);
    editLayout->addWidget(emailEdit,0,1);
    editLayout->addWidget(passwordLabel,1,0);
    editLayout->addWidget(passswordEdit,1,1);
    editLayout->addWidget(pop3AddressLabel,2,0);
    editLayout->addWidget(pop3AddressEdit,2,1);
    editLayout->addWidget(smtpAddressLabel,3,0);
    editLayout->addWidget(smtpAddressEdit,3,1);
    editLayout->addWidget(ownerEmailLabel,4,0);
    editLayout->addWidget(ownerEmailEdit,4,1);

    QVBoxLayout *leftLayout = new QVBoxLayout;
    leftLayout->addLayout(editLayout);
    leftLayout->addWidget(listenMailBox);

    QVBoxLayout *rightLayout  = new QVBoxLayout;
    rightLayout->addWidget(okButton);
    rightLayout->addWidget(cancelButton);

    QHBoxLayout *mainLayout = new QHBoxLayout(this);
    mainLayout->addLayout(leftLayout);
    mainLayout->addLayout(rightLayout);
    setLayout(mainLayout);
}

void SettingDialog::createConnections()
{

}
